//
// Created by jsjxsy on 2022/6/24.
//不识别
//#include <threads.h>
#include <pthread.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>

void printids(const char *s)
{
    pid_t      pid;
    pthread_t  tid;

    pid = getpid();
    tid = pthread_self();
    printf("%s pid %u tid %u (%#x)\n", s, (unsigned int)pid,
           (unsigned int)tid, (unsigned int)tid);
}

int *thr_fn(void *arg)
{
    printids(arg);
    return 1;
}

int main()
{
    int err;
    pthread_t ntid;
    err = pthread_create(&ntid, NULL, thr_fn, "new thread: ");
    if (err != 0) {
        fprintf(stderr, "can't create thread: %s\n", strerror(err));
        exit(1);
    }
    printids("main thread:");
    sleep(1);
    int res;
    pthread_join(ntid, &res);
    printf("res=%d", res);
    return 0;
}
